PWD := $(shell pwd)
CC  := $(CROSS_COMPILE)gcc
ROOTFS := /home/chzhou/code/2440/rootfs
MODULE_DIR := $(ROOTFS)/lib/modules/2.6.32.2
BIN_DIR := $(ROOTFS)/bin
INSTALLDIR := $(MODULE_DIR)

ifeq ($(CC), gcc)
	KDIR := /lib/modules/$(shell uname -r)/build
else
	KDIR := /home/chzhou/code/2440/kernel
endif

DEBUG = y

# Add your debugging flag (or not) to CFLAGS
ifeq ($(DEBUG),y)
	DEBFLAGS = -O -g -DSCULL_DEBUG # "-O" is needed to expand inlines
else
	DEBFLAGS = -O2
endif

EXTRA_CFLAGS += $(DEBFLAGS)

obj-m := scullpipe.o 

all: clean modules

modules:
	@echo "CC=$(CC)"
	@echo "PWD=$(PWD)"
	$(MAKE) -C $(KDIR) M=$(PWD) modules

install:
	cp scullpipe.ko $(INSTALLDIR)

clean:
	rm -fr *.o *~core *.ko *.mod.c *.order *.symvers *.markers .*cmd .tmp_versions \
		*.out

.PHONY: modules modules_install clean


